package com.example.client.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CrosConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry
                //允许跨域访问的接口
                .addMapping("/**")
                //允许跨域访问的前端域名
                .allowedOriginPatterns("*")
                //是否允许凭证，即允许携带cookie进行身份认证
                .allowCredentials(true)
                //允许的方法
                .allowedMethods("GET", "POST", "PUT", "DELETE")
                //允许携带的请求头信息
                .allowedHeaders("*");
    }
}
